<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>贪吃蛇游戏</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background-color: #f0f2f5;
            font-family: 'Poppins', sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
            padding: 10px;
        }

        .game-container {
            background-color: white;
            padding: 15px;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            max-width: 95vw;
            width: 430px;
        }

        canvas {
            border: 2px solid #4CAF50;
            border-radius: 10px;
            display: block;
            margin: 0 auto;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            max-width: 100%;
            height: auto;
            image-rendering: pixelated;
            image-rendering: crisp-edges;
        }

        .score {
            text-align: center;
            font-size: clamp(20px, 5vw, 28px);
            margin: 10px 0;
            color: #2E7D32;
            font-weight: 600;
        }

        .controls {
            text-align: center;
            margin: 10px 0;
            padding: 10px;
            background-color: #E8F5E9;
            border-radius: 8px;
        }

        .controls h3 {
            margin: 0 0 8px 0;
            color: #2E7D32;
            font-size: clamp(16px, 4vw, 20px);
        }

        .key {
            display: inline-block;
            padding: 4px 10px;
            background-color: #4CAF50;
            color: white;
            border-radius: 4px;
            margin: 0 3px;
            font-weight: bold;
            font-size: clamp(14px, 3.5vw, 16px);
        }

        .game-title {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 15px;
            justify-content: center;
        }

        .game-title img {
            width: 30px;
            height: 30px;
        }

        .game-title h1 {
            margin: 0;
            color: #1B5E20;
            font-size: clamp(20px, 5vw, 24px);
        }

        .key.space {
            padding: 4px 20px;
            margin-top: 8px;
        }

        @media (max-height: 600px) {
            .game-container {
                padding: 10px;
            }
            
            .controls {
                margin: 5px 0;
                padding: 5px;
            }
            
            .score {
                margin: 5px 0;
            }
            
            .game-title {
                margin-bottom: 5px;
            }
        }

        @keyframes fadeOut {
            from { opacity: 1; }
            to { opacity: 0; }
        }
        
        .level-info {
            display: block;
            margin-top: 8px;
            color: #2E7D32;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="game-container">
        <div class="game-title">
            <img src="https://api.iconify.design/emojione:snake.svg" alt="蛇图标">
            <h1>贪吃蛇游戏</h1>
        </div>
        <div class="score">分数：<span id="score">0</span></div>
        <canvas id="gameCanvas" width="400" height="400"></canvas>
        <div class="controls">
            <h3>游戏控制</h3>
            <p>
                上移: <span class="key">I</span>
                下移: <span class="key">K</span>
                左移: <span class="key">J</span>
                右移: <span class="key">L</span>
                <br>
                <span class="key space">空格</span> 开始/暂停
            </p>
        </div>
    </div>
    <script src="game.js"></script>
</body>
</html>